package com.hsmpay.mobile.service.terminal.impl;

import com.hsmpay.common.service.impl.BaseServiceSupport;
import com.hsmpay.mobile.dao.terminal.TerminalVersionDao;
import com.hsmpay.mobile.pojo.terminal.TerminalVersion;
import com.hsmpay.mobile.service.terminal.TerminalVersionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 终端版本 服务类接口 terminalVersionService
 * 对应Dao terminalTypeDao
 *
 * @param <Entity>
 * @param <Query>
 * @author 颜铃璋
 *         创建时间： 2013-08-20
 */
@Service("terminalVersionService")
public class TerminalVersionServiceImpl extends BaseServiceSupport<TerminalVersion, Long> implements TerminalVersionService<TerminalVersion, Long> {
    @Resource(name = "terminalVersionDao")
    private TerminalVersionDao<TerminalVersion, Long> terminalVersionDao;

    /**
     * 查询最新版本
     *
     * @param terminalId
     * @param clientType
     * @param roleId
     * @param versionType
     * @return
     * @throws Exception
     */
    public TerminalVersion searchLatestVersion(Long terminalId, Integer clientType, Long roleId, Integer versionType) throws Exception {
        TerminalVersion paramVersion = new TerminalVersion();
        paramVersion.setTerminalId(terminalId);
        paramVersion.setRoleId(roleId);
        paramVersion.setClientType(clientType);
        paramVersion.setVersionType(versionType);
        return terminalVersionDao.searchLatestVersion(paramVersion);
    }

    /**
     * 查询当前版本
     *
     * @param version
     * @param terminalId
     * @param clientType
     * @param roleId
     * @return
     * @throws Exception
     */
    public TerminalVersion searchNowVersion(String version, Long terminalId, Integer clientType, Long roleId) throws Exception {
        TerminalVersion paramVersion = new TerminalVersion();
        paramVersion.setVersion(version);
        paramVersion.setTerminalId(terminalId);
        paramVersion.setRoleId(roleId);
        paramVersion.setClientType(clientType);
        return terminalVersionDao.searchEntity(paramVersion);
    }

}
